extends Resource
class_name FactionEntity

var faction_id:int
var faction_name:String
# 君主id
var king_id:int
var city_list:Array[CityEntity]

var total_city:int:
	get:
		return city_list.size()

var total_gold:int:
	get:
		return city_list.reduce(func (perv:int,city:CityEntity): return  perv + city.gold_value,0)
		
var total_food:int:
	get:
		return city_list.reduce(func (perv:int,city:CityEntity): return  perv + city.food_value,0)
		
var total_soldiers:int:
	get:
		return city_list.reduce(func (prev:int,city:CityEntity): return prev + city.total_soliders,0)

var total_hero:int:
	get:
		return city_list.reduce(func (prev:int,city:CityEntity): return  prev + city.hero_list.size(),0)
		
var total_population:int:
		get:
			return city_list.reduce(func (prev:int,city:CityEntity): return prev + city.population_value,0)
	
var hero_list:Array[HeroEntity]:
	get:
		var list:Array[HeroEntity] = []
		for c in city_list:
			for h in c.hero_list:
				list.push_back(h)
				pass
			pass
		return list
		
func get_king()->HeroEntity:
	var tar:HeroEntity
	for h in hero_list:
		if h.hero_id == king_id:
			tar = h
			break
		pass
	return tar
	pass
